﻿namespace YnabCsvConverter.Core.Tests
{
   using Converters;
   using NUnit.Framework;

   /// <summary>
   /// Unit Test for the "ING DiBa" converter
   /// </summary>
   [TestFixture]
   public class IngDiBaTests
   {
      /// <summary>
      /// The subject under test.
      /// </summary>
      private IngDiBaConverter _sut;

      /// <summary>
      /// Initializes a new instance of the <see cref="IngDiBaTests" /> class.
      /// </summary>
      public IngDiBaTests()
      { 
      }

      /// <summary>
      /// Tests the setup.
      /// </summary>
      [TestFixtureSetUp]
      public void TestSetup()
      {
         _sut = new IngDiBaConverter();
      }

      /// <summary>
      /// Test if a ING DiBa record is converted to a ynab record.
      /// </summary>
      [Test]
      public void ConvertRecord_IngDiBaRecordWithInflow_ToYnabRecord()
      {
         // Given
         var record = new IngDiBaRecord()
         {
            AccountNumber = "123456789",
            Text = "Income Äther",
            DateTime = "31.12.2012",
            Currency = "EUR",
            Inflow = "98,76",
            Outflow = "0,00"
         };

         // When
         var ynabRecord = _sut.ConvertRecord(record);

         // Then
         var expectedYnabRecord = new YnabRecord
         {
            Date = "12/31/2012",
            Payee = "Income Äther",
            Category = "",
            Memo = "",
            Outflow = "",
            Inflow = "98.76",
         };

         Assert.That(ynabRecord, Is.EqualTo(expectedYnabRecord));
      }

      /// <summary>
      /// Test if a ING DiBa record is converted to a ynab record.
      /// </summary>
      [Test]
      public void ConvertRecord_IngDiBaRecordWithOutflow_ToYnabRecord()
      {
         // Given
         var record = new IngDiBaRecord()
         {
            AccountNumber = "123456789",
            Text = "Income Äther",
            DateTime = "31.12.2012",
            Currency = "EUR",
            Inflow = "0,00",
            Outflow = "12,34"
         };

         // When
         var ynabRecord = _sut.ConvertRecord(record);

         // Then
         var expectedYnabRecord = new YnabRecord
         {
            Date = "12/31/2012",
            Payee = "Income Äther",
            Category = "",
            Memo = "",
            Outflow = "12.34",
            Inflow = "",
         };

         Assert.That(ynabRecord, Is.EqualTo(expectedYnabRecord));
      }
   }
}
